/*
 * @lc app=leetcode.cn id=2011 lang=typescript
 *
 * [2011] 执行操作后的变量值
 */

// @lc code=start
function finalValueAfterOperations(operations: string[]): number {
    return operations.reduce((col, cur) => {
        switch (cur) {
            case "++X":
                return col + 1;
            case "X++":
                return col + 1;
            case "--X":
                return col - 1;
            case "X--":
                return col - 1;
        }
        return col;
    }, 0);
}
// @lc code=end
